package viewbuilder

import org.junit.Test
import groovy.xml.MarkupBuilder

import static org.junit.Assert.assertEquals


class TablePageTest {


    @Test
    void oddRowsAreHighlighted() {

        def writer = new StringWriter()
        def builder = new MarkupBuilder(writer)

        TablePage page = new TablePage()
        page.render(builder, [1,2,3,4])

        def html = new XmlSlurper().parseText(writer.toString())
        def table = html.body.table
        assertEquals(4, table.tr.size())
        assertEquals('highlight', table.tr[0].@'class'.text())
        assertEquals('', table.tr[1].@'class'.text())
        assertEquals('highlight', table.tr[2].@'class'.text())
        assertEquals('', table.tr[3].@'class'.text())

    }

}